jQ(function(){
	jQ("div.my_clips_menu a.clipmanage").addClass("clipmanageonit");
	jQ("input.hminput").val(0);
	jQ("#replycontent").val("");
	jQ("input.searchdefault").val("输入您要搜索的档期内容");
	jQ("#left_clip_list").empty();
	jQ("#mainpart_list_content").data("currentpage",0);
	jQ("#clipmanagehead li").click(function(){
		var qb=jQ(this).attr("queryby");
		if(qb=="cache"||qb=="recycle"){
			window.location.href=jQ("#ctxVal").val()+"/myclip/clip_"+qb+".html";
		}else{
			window.location.href=jQ("#ctxVal").val()+"/myclip/clip_list.html#"+qb;
		}
	});
	analyzeUrl();
	initUserInterface();
	loadCacheAndClockAndRecycleCount();
	jQ("#setalertdatapicker").datepicker({dateFormat: 'yy-mm-dd',  
		beforeShow: function(i,e){  
		var z = jQuery(i).closest(".ui-dialog").css("z-index") + 4;  
		e.dpDiv.css('z-index', z);  
		e.dpDiv.css('font', "14px \"Trebuchet MS\", sans-serif");
	}});
	jQ("#viewopt").dialog({
		modal: true,
		bgiframe: true,
		autoOpen: false,
		closeOnEscape:false,
		draggable:false,
		height:200,
		buttons: {
			
			"确定": function() {
				var opt=jQ("#viewopt");
				var triggerfun=opt.data("function");
				opt.trigger(triggerfun);
				opt.removeData("function");
				jQ("#viewopt_p").hide();
				jQ("#viewopt_img").show();
				activeBtnOnDialog("viewopt",false);
				//jQ(this).dialog('close');
			},
			"取消": function() {
				var viewopt=jQ("#viewopt");
				var triggerfun=jQ("#viewopt").data("function");
				viewopt.unbind(triggerfun);
				viewopt.find("input.eventid").val("");
				viewopt.removeData("function");
				jQ(this).dialog('close');
			}
		},
		close: function() {
			jQ("#viewopt_p").show();
			jQ("#viewopt_img").hide();
			activeBtnOnDialog("viewopt",true);
		},
		open:function(){
		}
	});
});

function loadCacheAndClockAndRecycleCount(){
	var eventid=jQ("#viewopt_eventid").val(); 
	jQ.ajax({
		type: "POST",
		url:"manageClipAjax!loadCacheAndClockAndRecycleCount.action",
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj['result']){
					
					var alerttotalcount=dataObj.alerttotalcount;
					var invitetotalcount=dataObj.invitetotalcount;
					
					
					alerttotalcount=alerttotalcount>99?"99+":alerttotalcount;
					invitetotalcount=invitetotalcount>99?"99+":invitetotalcount;
					
					jQ("#invitecount>span.count").empty().append(invitetotalcount);
					jQ("#alertcount>span.count").empty().append(alerttotalcount);
					
				}
			}
		}
	});
}

function initUserInterface(){
	var usertype=eval(jQ("#var_usertype").val());
	if(usertype==2){
	}else{
		initContacts();
	}
	
}

function analyzeUrl(){
	var eventid=eval(getParameter("eventid"));
	if(isNaN(eventid)||eventid==null){
		var shareid=getUniqueParameter();
		if(shareid==null||shareid.length==0)
			window.location.href=jQ("#ctxVal").val()+"/myclip/clip_list.html";
		else
			getClipDetail(0,shareid);
	}else{
		getClipDetail(eventid,"");
	}
}



function showQuickContactGroup(id,name,membercount){
	var flag=false;
	if(jQ("#contactgrouplist").css("display")=="none"){
		flag=true;
	}
	var canbeadd=true;
	jQ("li",jQ("#contactgrouplist")).each(function(){
		var groupid=eval(jQ(this).attr("groupid"));
		if(groupid==eval(id)){
			canbeadd=false;
			return false;
		}
	});
	if(!canbeadd)
		return;
	var countstr;
	if(membercount>99){
		countstr=membercount+"+";
	}else{
		countstr=membercount;
	}
	var html="<li groupid='"+id+"'>";
	html+="<span class=\"groupicon\"></span>";
	html+="<span class=\"groupname\">"+name+"</span>";
	html+="<span class=\"groupcount\">["+countstr+"]</span>";
	html+="<a onclick='deleteContactGroup(this);'></a></li>";
	jQ("#contactgrouplist").append(html);
	if(jQ("#contactgrouplist").css("display")=="none"){
		jQ("#contactgrouplist").show();
	}
}

function deleteContactGroup(obj){
	var groupid=jQ(obj).parent().attr("groupid");
	var li=jQ("#contactgroup li[groupid="+groupid+"]");
	li.find("input:checkbox").attr("checked",false);
	jQ(obj).parent().remove();
	if(jQ("li",jQ("#contactgrouplist")).length==0){
		jQ("#contactgrouplist").hide();
	}
}

function initPrevNextButton(){
	jQ("#nextclipbtn").unbind("click").bind("click",function(){
		jQ.ajax({
			type:"POST",
			url: "eventAjax!getDetailClipidByPosition.action",
			data:{
				move:1,
				eventid:eval(jQ("#clipevent-eventid").val())
			},
			success:function(data){
				if(data!=null){
					var dataObj=eval("("+data+")");//转换为json对象
					if(dataObj.result){
						var eventid=dataObj.eventid;
						if(eventid==null){
							var shareid=dataObj.shareid;
							window.location.href=jQ("#ctxVal").val()+"/myclip/clip_detail.html?shareid="+shareid;
						}else
							window.location.href=jQ("#ctxVal").val()+"/myclip/clip_detail.html?eventid="+eventid;
					}else{
						alert(dataObj.msg);
					}
				}
			}
		});
	});
	jQ("#prevclipbtn").unbind("click").bind("click",function(){
		jQ.ajax({
			type:"POST",
			url: "eventAjax!getDetailClipidByPosition.action",
			data:{
				move:-1,
				eventid:eval(jQ("#clipevent-eventid").val())
			},
			success:function(data){
				if(data!=null){
					var dataObj=eval("("+data+")");//转换为json对象
					if(dataObj.result){
						var eventid=dataObj.eventid;
						if(eventid==null){
							var shareid=dataObj.shareid;
							window.location.href=jQ("#ctxVal").val()+"/myclip/clip_detail.html?shareid="+shareid;
						}else
							window.location.href=jQ("#ctxVal").val()+"/myclip/clip_detail.html?eventid="+eventid;
					}else{
						alert(dataObj.msg);
					}
				}
			}
		});
	});
}

function getClipDetail(eventid,shareid){
	jQ.ajax({
		type:"POST",
		url: "manageClipAjax!loadMyclips.action",
		data:{
			eventid:eval(eventid),
			shareid:shareid
		},
		success:function(data){
			if(!data.result){
				//加入无效页面
				jQ("#clip_detail_main").hide();
				jQ("#nonecliptip").show();
				return;
			}
			
				//initPrevNextButton();
			var mobilenotice=eval(data.mobilenotice);
			if(mobilenotice==1){
				jQ(".hasmobilechoose").show();
			}else{
				jQ(".hasmobilechoose").hide();
			}
				
				
			jQ("#clip_detail_main").show();
			var eventobj=data.clipevent;
			var eventid=eval(eventobj.eventid);
			jQ("#clipevent-eventid").val(eventid);
				
			
			var title=eventobj.title;
			var starttime=eval(eventobj.starttime);
			var endtime=eval(eventobj.endtime);
			var iswholeday=eval(eventobj.iswholeday);
			var content=eventobj.content;
			var clocktime=eval(eventobj.clocktime);
			var processstatus=eval(eventobj.processstatus);
			var clipstatus=eval(eventobj.clipstatus);
			var reliedclip=eval(eventobj.reliedclip);
			
			var uname=eventobj.uname;
			var unameid=eventobj.unameid;
			var unamelogo=eventobj.unamelogo;
			var unameslogo=eventobj.unameslogo;
			var clipiscc=eventobj.clipiscc;
			var cliptype=eval(eventobj.cliptype);
			var seid=eventobj.seid;
			var isuserself=eventobj.isuserself;
			var shareid=eventobj.shareid;
			var eventtype=eventobj.eventtype;
			var eventisinterested=eventobj.eventisinterested;
			var clipeventpic=eventobj.clipeventpic;
			
			var currentusertype=eval(jQ("#var_usertype").val());
			if(typeof(eventobj.eventisinterested)=='undefined'){
				jQ("#clipevent-eventid").data("eventisinterested",false);
			}else
				jQ("#clipevent-eventid").data("eventisinterested",eventisinterested);
			if(reliedclip>0){
				loadClipMessage(reliedclip);
			}else{
				loadClipMessage(eventid);
			}
			initDetailTimeCalendar(starttime,iswholeday,endtime);
			//统计
			jQ("#clipevent-eventid").data("shareid",shareid);
			jQ("#clipevent-eventid").data("starttime",starttime);
			jQ("#clipevent-eventid").data("title",title);
			jQ("#clipevent-eventid").data("seid",seid);
			jQ("#clipevent-eventid").data("processstatus",processstatus);
			jQ("#clipevent-eventid").data("reliedclip",reliedclip);
			jQ("#clipevent-eventid").data("isuserself",isuserself);
			jQ("#clipevent-eventid").data("eventtype",eventtype);
			//hidden
			jQ("#clipevent-eventid").val(eventid);
			jQ("#clipevent-clocktime").val(clocktime);
			
			jQ("#event-unamelogo").attr("title",uname);
			jQ("#event-unamelogo").css({"background":"url('"+unamelogo+"')"});
			jQ("#event-unamelogo").bind("click",function(){
				window.location.href=jQ("#ctxVal").val()+"/myclip/user.html?"+unameid;
			});
			jQ("#event-uname").empty().append(uname);
			if(clipiscc)
				jQ("#event-uname").next().show();
			else
				jQ("#event-uname").next().hide();
			if(cliptype==3){
				if(eventtype==2&&seid==0){
					jQ("#event-cliptype").hide();
				}else
					jQ("#event-cliptype").attr("class","invite").show();
			}else if(cliptype==4){
				jQ("#event-cliptype").attr("class","request").show();
			}else{
				jQ("#event-cliptype").hide();
			}
			if(eventtype==2&&seid>0){
				if(reliedclip!=seid){
					var sourceeventid=eventobj.sourceeventid;
					var sourceuid=eventobj.sourceuid;
					var sourceuname=eventobj.sourceuname;
					var sourceulogo=eventobj.sourceulogo;
					jQ("#event-sourcelogo").css({"background":"url('"+sourceulogo+"')"});
					jQ("#event-sourcelogo").attr("title",sourceuname);
					jQ("#event-sourcelogo").bind("click",function(){
						window.location.href=jQ("#ctxVal").val()+"/myclip/user.html?"+sourceuid;
					});
					jQ("#event-sourcelogo").parent().children().show();
					var invitetime=eventobj.invitetime;
					if(typeof(invitetime)!='undefined'&&eval(invitetime)>0){
						jQ("#event-sourcelogo").parent().find("i.invitetime").empty().append("<strong>邀请时间：</strong>"+formateDetailTime(eval(invitetime)));
					}
				}
			}
				
			//时间
			if(iswholeday){
				if(eventtype==2||cliptype==1)
					jQ("#event-time").empty().append("<span style='width:auto;padding-top:0px;'>开始于</span><b>"+formateDetailTime(starttime)+"</b>");
				else
					jQ("#event-time").empty().append("<span style='width:auto;padding-top:0px;'>开始于</span><b>"+formateTitleTime(starttime)+"</b>");
			}else{
				if(eventtype==2||cliptype==1)
					jQ("#event-time").empty().append("<b>"+formateDetailTime(starttime)+"</b><b>至</b><b>"+formateDetailTime(endtime)+"</b>");
				else
					jQ("#event-time").empty().append("<b>"+formateTitleTime(starttime)+"</b><b>至</b><b>"+formateTitleTime(endtime)+"</b>");
			}
			/*if(processstatus==-1){
				jQ("#event-processtatus").removeClass().addClass("edt_before").empty().append("未开始");
			}else if(processstatus==0){
				jQ("#event-processtatus").removeClass().addClass("edt_ing").empty().append("进行中");
			}else if(processstatus==1){
				jQ("#event-processtatus").removeClass().addClass("edt_over").empty().append("已结束");
			}else if(processstatus==2){
				jQ("#event-processtatus").removeClass().addClass("edt_stop").empty().append("已停止");
			}*/
			//内容
			jQ("#event-title").empty().append(title);
			//详情
			if(content.length>0||clipeventpic.length>0){
				if(content.length>0)
					jQ("#event-detail").empty().append(content);
				if(clipeventpic.length>0)
					jQ("#event-detail").after("<img src='"+jQ("#ctxVal").val()+"/clippic/"+clipeventpic+"'/>");
				jQ("#event-detail").parent().show();
			}else{
				jQ("#event-detail").parent().hide();
			}
			//按钮区
			if(cliptype==1){
				jQ("#clippoint-zone").hide();
				//jQ("#clipevent-shieldedopt").empty();
				var html="<a class='del' title=\"删除该档期\">取消档期</a>";
				if(clocktime>0){
					html+="<div class=\"setclock\">";
					html+="<div class=\"middle\">";
					html+="<i class=\"clock\"></i>";
					html+="<span class=\"timedata\">"+formateDetailTime(clocktime)+"</span>";
					html+="<a class=\"cancel\"></a>";
					html+="</div>";
					html+="</div>";
				}else{
					html+="<div class=\"setclock\">";
					html+="<div class=\"middle\">";
					html+="<i class=\"clockoff\"></i>";
					html+="<a class=\"timeset\">设置提醒</a>";
					html+="</div>";
					html+="</div>";
				}
				jQ("#clipevent-opt").empty().append(html);
			}else if(cliptype==4){
				jQ("#clippoint-zone").hide();
				if(currentusertype!=2){
					if(isuserself){
						var html="<a class='del' title=\"删除该档期\">取消档期</a>";
						//评论放到下面去
						jQ("#clipevent-opt").empty().append(html);
						jQ("#shareoutzone").show();
						initDetailShareOutofSite();
						
					}else{
						var html="<a class='atta' title=\"邀请TA一起参与活动\">邀请TA</a>";
						jQ("#clipevent-opt").empty().append(html);
					}
				}
			}else if(cliptype==3){
				var usertype=eval(jQ("#var_usertype").val());
				if(usertype==2){
					if(isuserself){
						//	商家看自己
						jQ("#clippoint-zone div.aboutpppart").hide();
						jQ("#user2ccliphr").hide();
						loadCCShareInfo(eventid);
						var html="<a class='del' title=\"删除该档期\">取消档期</a>";
						jQ("#clipevent-opt").empty().append(html);
					}
				}else{
					//用户
					if(isuserself||(eventtype==2&&seid==0)){
						jQ("#shareoutzone").show();
						initDetailShareOutofSite();
					}
					if(eventtype==2&&(seid==0||reliedclip==seid)){
						var dealeventid=0;
						if(seid>0){
							dealeventid=seid;
						}else{
							dealeventid=eventid;
						}
						loadCCShareInfo(dealeventid);
						jQ("#user2ccliphr").show();
						loadPPShareInfo(dealeventid);
						//直接看商家，或直接【感】商家的档期
						var isinterest=eventobj.eventisinterested;
						var isfavor=eventobj.isfavor;
						var interestcount=eventobj.interestcount;
						var favorcount=eventobj.favorcount;
						jQ("#clipevent-eventid").data("interestcount",interestcount);
						jQ("#clipevent-eventid").data("favorcount",favorcount);
						var html="";
						html+=getInterestBtnHTML(isinterest,interestcount);
						html+=getFavorBtnHTML(isfavor,favorcount);
						if(eventisinterested){
							if(clocktime>0){
								html+="<div class=\"setclock\">";
								html+="<div class=\"middle\">";
								html+="<i class=\"clock\"></i>";
								html+="<span class=\"timedata\">"+formateClockTime(clocktime)+"</span>";
								html+="<a class=\"cancel\"></a>";
								html+="</div>";
								html+="</div>";
							}else{
								html+="<div class=\"setclock\">";
								html+="<div class=\"middle\">";
								html+="<i class=\"clockoff\"></i>";
								html+="<a class=\"timeset\">设置提醒</a>";
								html+="</div>";
								html+="</div>";
							}
						}
						jQ("#clipevent-opt").empty().append(html);
					}else{
						jQ("#clippoint-zone div.aboutpppart span.title").text("邀请的好友");
						jQ("#clippoint-zone div.aboutccpart").hide();
						var isconfirmevent=eventobj.isconfirmevent;
						if(typeof(eventobj.isconfirmevent)=='undefined'){
							jQ("#clipevent-eventid").data("isconfirmevent",false);
						}else
							jQ("#clipevent-eventid").data("isconfirmevent",isconfirmevent);
						
						var dealeventid=0;
						if(reliedclip>0){
							dealeventid=reliedclip;
						}else{
							dealeventid=eventid;
						}
						jQ("#user2ccliphr").hide();
						loadPPShareInfo(dealeventid);
						var html="";
						if(isuserself&&reliedclip==0){
							html+="<a class=\"del\" title=\"删除该档期\">取消档期</a>";
							if(clocktime>0){
								html+="<div class=\"setclock\">";
								html+="<div class=\"middle\">";
								html+="<i class=\"clock\"></i>";
								html+="<span class=\"timedata\">"+formateDetailTime(clocktime)+"</span>";
								html+="<a class=\"cancel\"></a>";
								html+="</div>";
								html+="</div>";
							}else{
								html+="<div class=\"setclock\">";
								html+="<div class=\"middle\">";
								html+="<i class=\"clockoff\"></i>";
								html+="<a class=\"timeset\">设置提醒</a>";
								html+="</div>";
								html+="</div>";
							}
						}else{
							if(isconfirmevent){
								html+="<a class='quitclip' title='退出该活动'>退出活动</a>";
								if(clocktime>0){
									html+="<div class=\"setclock\">";
									html+="<div class=\"middle\">";
									html+="<i class=\"clock\"></i>";
									html+="<span class=\"timedata\">"+formateDetailTime(clocktime)+"</span>";
									html+="<a class=\"cancel\"></a>";
									html+="</div>";
									html+="</div>";
								}else{
									html+="<div class=\"setclock\">";
									html+="<div class=\"middle\">";
									html+="<i class=\"clockoff\"></i>";
									html+="<a class=\"timeset\">设置提醒</a>";
									html+="</div>";
									html+="</div>";
								}
							}else{
								var isshielded=eventobj.isshielded;
								if(isshielded==false){
									var eventisinterested=eventobj.eventisinterested;
									html+=getInterestBtnHTML(eventisinterested,null);
									if(eventisinterested||(isuserself&&reliedclip==0)){
										if(clocktime>0){
											html+="<div class=\"setclock\">";
											html+="<div class=\"middle\">";
											html+="<i class=\"clock\"></i>";
											html+="<span class=\"timedata\">"+formateDetailTime(clocktime)+"</span>";
											html+="<a class=\"cancel\"></a>";
											html+="</div>";
											html+="</div>";
										}else{
											html+="<div class=\"setclock\">";
											html+="<div class=\"middle\">";
											html+="<i class=\"clockoff\"></i>";
											html+="<a class=\"timeset\">设置提醒</a>";
											html+="</div>";
											html+="</div>";
										}
									}
									if(!eventisinterested)
										html+="<a class='msgopen' title='不再接收该档期的提示'>不再提示</a>";
									
								}else{
									html+="<a class='msgclose' title='接收该档期的提示'>接收提示</a>";
								}
							}
						}
						jQ("#clipevent-opt").empty().append(html);
					}
				}
			}
			jQ("#clipevent-opt a.uninterest").bind("click",interestClipevent);
			jQ("#clipevent-opt a.interest").bind("click",uninterestClipevent);
			jQ("#clipevent-opt a.unfavor").bind("click",favorClipevent);
			jQ("#clipevent-opt a.favor").bind("click",unfavorClipevent);
			jQ("#clipevent-opt a.del").bind("click",delEventNotice);
			jQ("#clipevent-opt a.quitclip").bind("click",quickClipevent);
			jQ("#clipevent-opt a.atta").bind("click",function(){
				var tempday=new Date();
				tempday.setTime(starttime);
				window.location.href=jQ("#ctxVal").val()+"/myclip/add_clip.html?year="+tempday.getFullYear()+
				"&month="+(tempday.getMonth()+1)+
				"&day="+tempday.getDate()+
				"&invites="+unameid;
			});
			
			jQ("#clipevent-opt a.msgopen").unbind("click").bind("click",shieldClipmessage);
			jQ("#clipevent-opt a.msgclose").unbind("click").bind("click",acceptClipmessage);
			
			jQ("#clipevent-opt").find("div.setclock").find("div.middle a.timeset").unbind("click").bind("click",setclockClipevent);
			jQ("#clipevent-opt").find("div.setclock").find("div.middle a.cancel").unbind("click").bind("click",cancelClockevent);
			
			
		}
	});
}

function quickClipevent(){
	var eventid=eval(jQ("#clipevent-eventid").val());
	jQ.ajax({
		type: "POST",
		url:"shareAjax!quitClip.action",
		data:{
			eventid:eval(eventid)
		},
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj.result){
					clip_tips("成功退出活动");
					window.location.href=jQ("#ctxVal").val()+"/myclip/clip_list.html";
				}else{
					
				}
			}
		}
	});
}

function delEventNotice(){
	var info="您确定要删除当前档期么？";
	var title="删除档期";
	
	var opt=jQ("#viewopt");
	opt.bind("delEvent",delEvent);
	opt.data("function","delEvent");
	jQ("#viewopt_p").empty().append(info);
	jQ("#viewopt").dialog("option", "title", title);
	jQ("#viewopt").dialog("open");
	
}

function delEvent(){
	var eventid=eval(jQ("#clipevent-eventid").val());
	
	jQ.ajax({
		type: "POST",
		url:"eventAjax!deleteEvent.action",
		data:{
			eventid:eventid
		},
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj['result']){
					clip_tips("成功删除档期");
					window.location.href=jQ("#ctxVal").val()+"/myclip/clip_list.html";
				}else{
					
				}
			}
		}
	});
	
}


function favorClipevent(){
	var btnobj=jQ(this);
	var dealeventid=0;
	var seid=eval(jQ("#clipevent-eventid").data("seid"));
	if(seid>0){
		dealeventid=seid;
	}else{
		dealeventid=eval(jQ("#clipevent-eventid").val());
	}
	jQ.ajax({
		type: "POST",
		url:"shareAjax!favorShareEvent.action",
		data:{
			eventid:eval(dealeventid)
		},
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj.result){
					var favorcount=jQ("#clipevent-eventid").data("favorcount");
					favorcount++;
					jQ("#clipevent-eventid").data("favorcount",favorcount);
					var favorcountstr=favorcount>99999?"99999+":""+favorcount;
					btnobj.text("取消喜欢("+favorcountstr+")");
					btnobj.removeClass().addClass("favor").attr("title","取消喜欢该档期");
					btnobj.unbind("click").bind("click",unfavorClipevent);
				}else{
					
				}
			}
		}
	});
}

function unfavorClipevent(event){
	var btnobj=jQ(this);
	var dealeventid=0;
	var seid=eval(jQ("#clipevent-eventid").data("seid"));
	if(seid>0){
		dealeventid=seid;
	}else{
		dealeventid=eval(jQ("#clipevent-eventid").val());
	}
	jQ.ajax({
		type: "POST",
		url:"shareAjax!unfavorShareEvent.action",
		data:{
			eventid:eval(dealeventid)
		},
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj.result){
					var favorcount=jQ("#clipevent-eventid").data("favorcount");
					favorcount--;
					jQ("#clipevent-eventid").data("favorcount",favorcount);
					var favorcountstr=favorcount>99999?"99999+":""+favorcount;
					btnobj.text("喜欢("+favorcountstr+")");
					btnobj.removeClass().addClass("unfavor").attr("title","喜欢该档期");
					btnobj.unbind("click").bind("click",favorClipevent);
				}else{
					
				}
			}
		}
	});
}


function shieldClipmessage(){
	var btnobj=jQ(this);
	var eventid=eval(jQ("#clipevent-eventid").val());
	jQ.ajax({
		type: "POST",
		url:"eventAjax!shieldClipmessage.action",
		data:{
			eventid:eventid
		},
		success:function(data){
			if(data.result){
				btnobj.prev().hide();
				btnobj.removeClass().addClass("msgclose").attr("title","接收该档期的提示");
				btnobj.text("接收提示");
				btnobj.unbind("click").bind("click",acceptClipmessage);
			}else{
				
			}
		}
	});
}

function acceptClipmessage(){
	var btnobj=jQ(this);
	var eventid=eval(jQ("#clipevent-eventid").val());
	jQ.ajax({
		type: "POST",
		url:"eventAjax!acceptClipmessage.action",
		data:{
			eventid:eval(eventid)
		},
		success:function(data){
			if(data.result){
				if(jQ("#clipevent-opt").find("a[class!='msgclose']").length<=0){
					var html="";
					html+="<a class='uninterest' title='表示感兴趣'>感兴趣</a>";
					btnobj.before(html);
					jQ("#clipevent-opt").find("a.uninterest").unbind("click").bind("click",interestClipevent);
				}else
					jQ("#clipevent-opt").find("a.uninterest").show();
				
				btnobj.removeClass().addClass("msgopen").attr("title","不再接收该档期的提示");
				btnobj.text("不再提示");
				btnobj.unbind("click").bind("click",shieldClipmessage);
			}else{
				
			}
		}
	});
}

function interestClipevent(){
	var eventid=eval(jQ("#clipevent-eventid").val());
	var btnobj=jQ(this);
	jQ.ajax({
		type: "POST",
		url:"shareAjax!interestShareEvent.action",
		data:{
			eventid:eval(eventid)
		},
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj.result){
					var eventtype=eval(jQ("#clipevent-eventid").data("eventtype"));
					var seid=eval(jQ("#clipevent-eventid").data("seid"));
					var reliedclip=eval(jQ("#clipevent-eventid").data("reliedclip"));
					jQ("#clipevent-eventid").data("eventisinterested",1);
					
					if(eventtype==2&&seid==0){
						var interestcount=eval(jQ("#clipevent-eventid").data("interestcount"));
						interestcount++;
						jQ("#clipevent-eventid").data("interestcount",interestcount);
						var interestcountstr=interestcount>99999?"99999+":""+interestcount;
						btnobj.text("取消感兴趣("+interestcountstr+")");
					}else{
						btnobj.text("取消感兴趣");
					}
					
					
					btnobj.removeClass().addClass("interest");
					btnobj.unbind("click").bind("click",uninterestClipevent);
					jQ("#clipevent-opt a.msgopen").remove();
//					jQ("#clipevent-shieldedopt").empty(); //清楚不再提醒按钮
					var temphtml="";
					temphtml+="<div class=\"setclock\">";
					temphtml+="<div class=\"middle\">";
					temphtml+="<i class=\"clockoff\"></i>";
					temphtml+="<a class=\"timeset\">设置提醒</a>";
					temphtml+="</div>";
					temphtml+="</div>";
					btnobj.parent().find("a:last").after(temphtml);
					btnobj.parent().find("div.setclock").find("div.middle a.timeset").unbind("click").bind("click",setclockClipevent);
					if((seid>0&&seid!=reliedclip)||eventtype==1){
						var pppart=jQ("#clippoint-zone").find("div.aboutpppart");
						var userlistul=pppart.find("ul.sharemembers");
						userlistul.find("li:first").addClass("iton");
					}
				}else{
					alert(dataObj.msg);
					window.location.reload();
				}
			}
		}
	});
	
}

function uninterestClipevent(){
	var eventid=eval(jQ("#clipevent-eventid").val());
	var btnobj=jQ(this);
	jQ.ajax({
		type: "POST",
		url:"shareAjax!uninterestShareEvent.action",
		data:{
			eventid:eventid
		},
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj.result){
					var eventtype=eval(jQ("#clipevent-eventid").data("eventtype"));
					var seid=eval(jQ("#clipevent-eventid").data("seid"));
					var reliedclip=eval(jQ("#clipevent-eventid").data("reliedclip"));
					btnobj.removeClass().addClass("uninterest");
					btnobj.unbind("click").bind("click",interestClipevent);
					btnobj.parent().find("div.setclock").remove();
					if(seid==0&&eventtype==2){
						var interestcount=eval(jQ("#clipevent-eventid").data("interestcount"));
						interestcount--;
						jQ("#clipevent-eventid").data("interestcount",interestcount);
						var interestcountstr=interestcount>99999?"99999+":""+interestcount;
						btnobj.text("感兴趣("+interestcountstr+")");
					}else{
						btnobj.text("感兴趣");
						jQ("#clipevent-opt a:last").after("<a title=\"不再接收该档期的提示\" class=\"msgopen\">不再提示</a>"); 
					}
					if((seid>0&&seid!=reliedclip)||eventtype==1){
						var pppart=jQ("#clippoint-zone").find("div.aboutpppart");
						var userlistul=pppart.find("ul.sharemembers");
						userlistul.find("li:first").removeClass("iton");
					}
					jQ("#clipevent-opt").find("a.msgopen").unbind("click").bind("click",shieldClipmessage);
					
				}else{
					clip_tips(dataObj.msg);
					window.location.reload();
				}
			}
		}
	});
}

function setclockClipevent(){
	jQ(this).prev().removeClass().addClass("clock");
	jQ(this).hide();
	var html="";
	html+="<input class=\"date\"/>";
	html+="<input class=\"time hour\" value=\"0\"/>";
	html+="<span class=\"time\">时</span>";
	html+="<input class=\"time min\" value=\"0\"/>";
	html+="<span class=\"time\">分</span>";
	html+="<a class=\"confirm\"></a>";
	html+="<a class=\"cancel\"></a>";
	jQ(this).after(html);
	jQ(this).nextAll("input.date").datepicker({
		yearRange : '1950:2020',
		dateFormat:'yy-mm-dd',
		changeMonth:true,
		changeYear:true,
		beforeShow: function(i,e){  
		var z = jQuery(i).closest(".ui-dialog").css("z-index") + 4;  
		e.dpDiv.css('z-index', z);  
		e.dpDiv.css('font', "14px \"Trebuchet MS\", sans-serif");
		}
    });
	jQ(this).nextAll("input.hour").unbind("blur").bind("blur",hourinput);
	jQ(this).nextAll("input.min").unbind("blur").bind("blur",mininput);
	jQ(this).nextAll("a.cancel").unbind("click").bind("click",function(){
		var clockobj=jQ(this).prevAll("i.clock");
		clockobj.removeClass("clock").addClass("clockoff");
		clockobj.nextAll().remove();
		clockobj.after("<a class=\"timeset\">设置提醒</a>");
		clockobj.nextAll("a.timeset").unbind("click").bind("click",setclockClipevent);
		
	});
	jQ(this).nextAll("a.confirm").unbind("click").bind("click",function(){
		var alertdate=jQ(this).prevAll("input.date").datepicker( "getDate" );
		if(alertdate==null||alertdate.length<=0){
			clip_tips("请选择提醒日期。");
			return false;
		}
		var alerthour=eval(jQ("input.hour").val());
		var alertmin=eval(jQ("input.min").val());
		alertdate.setHours(alerthour);
		alertdate.setMinutes(alertmin);
		var alertlong=alertdate.getTime();
		var nowdate=new Date();
		if(alertlong<nowdate){
			clip_tips("提醒的时间应该是将来的时间。");
			return false;
		}
		var clockobj=jQ(this).prevAll("i.clock");
		var eventid=eval(jQ("#clipevent-eventid").val());
		jQ.ajax({
			type: "POST",
			url:"eventAjax!addEventClock.action",
			data:{
				eventid:eval(eventid),
				alerttime:alertlong,
				mobilenotice:0
			},
			success:function(data){
				if(data!=null){
					var dataObj=eval("("+data+")");//转换为json对象
					if(dataObj.result){
						var temphtml="";
						temphtml+="<span class=\"timedata\">"+formateDetailTime(alertlong)+"</span>";
						temphtml+="<a class=\"cancel\"></a>";
						clockobj.nextAll().remove();
						clockobj.after(temphtml);
						clockobj.nextAll("a.cancel").unbind("click").bind("click",cancelClockevent);
					}else{
						
					}
				}
			}
		});
	});
	jQ(this).remove();
}



function cancelClockevent(){
	var eventid=eval(jQ("#clipevent-eventid").val());
	var clockobj=jQ(this).prevAll("i.clock");
	jQ.ajax({
		type: "POST",
		url:"eventAjax!cancelClock.action",
		data:{
			eventid:eval(eventid)
		},
		success:function(data){
			if(data.result){
				var temphtml="";
				temphtml+="<a class=\"timeset\">设置提醒</a>";
				clockobj.nextAll().remove();
				clockobj.after(temphtml);
				clockobj.removeClass("clock").addClass("clockoff");
				clockobj.next().unbind("click").bind("click",setclockClipevent);
			}else{
				
			}
		}
	});
}


function loadPPShareInfo(eventid){
	var isconfirmevent=eval(jQ("#clipevent-eventid").data("isconfirmevent"));
	if(isconfirmevent){
		var topobj=jQ("#clippoint-zone").prevAll("div.part_right_top");
		topobj.append("<img src=\""+jQ("#ctxVal").val()+"/image/confirmevent_status.png\"></img>");
		jQ("#aboutpppart-title").text("参加的好友");
	}else{
		var reliedclip=eval(jQ("#clipevent-eventid").data("reliedclip"));
		var seid=eval(jQ("#clipevent-eventid").data("seid"));
		var eventtype=eval(jQ("#clipevent-eventid").data("eventtype"));
		if((seid==0||seid==reliedclip)&&eventtype==2){
			jQ("#aboutpppart-title").text("感兴趣的好友");
		}else
			jQ("#aboutpppart-title").text("邀请的好友");
	}
	var finaleventid=eventid;
	jQ.ajax({
		type: "POST",
		url:"manageClipAjax!loadPPShareInfo.action",
		data:{
			eventid:eventid
		},
		success:function(data){
			if(data.size>0){
				var userlist=data.users;
				var clipiscc=data.clipiscc;
				var processstatus=eval(jQ("#clipevent-eventid").data("processstatus"));
				var isuserself=eval(jQ("#clipevent-eventid").data("isuserself"));
				var seid=eval(jQ("#clipevent-eventid").data("seid"));
				var reliedclip=eval(jQ("#clipevent-eventid").data("reliedclip"));
				var eventtype=eval(jQ("#clipevent-eventid").data("eventtype"));
				var userhtml="<ul class='sharemembers'>";
				var eventisinterested=eval(jQ("#clipevent-eventid").data("eventisinterested"));
				if((seid==0||seid==reliedclip)&&eventtype==2){
					
				}else{
					if(!isuserself){
						if(eventisinterested){
							userhtml+="<li class=\"ele iton\" title='我'>";
						}else{
							userhtml+="<li class=\"ele\" title='我'>";
						}
						userhtml+="<a href=\""+jQ("#ctxVal").val()+"/myclip/user.html?"+jQ("#var_usertype").data("uid")+"\" style=\"background:url('"+jQ("#var_usertype").data("smallurl")+"')\"></a>";
						userhtml+="</li>";
					}
				}
				var interestedcount=0;
				for(var i=0;i<userlist.length;i++){
					var userobj=userlist[i];
					var uid=userobj.uid;
					var name=userobj.name;
					var smalllogo=userobj.smalllogo;
					var biglogo=userobj.biglogo;
					var tmpeventisinterested=userobj.eventisinterested;
					if(tmpeventisinterested){
						if(isconfirmevent)
							userhtml+="<li class=\"ele iton\" title='"+name+"'>";
						else
							userhtml+="<li class=\"ele iton\" title='感兴趣的好友："+name+"'>";
						interestedcount++;
					}else{
						if(isconfirmevent)
							userhtml+="<li class=\"ele\" title='退出活动的好友："+name+"'>";
						else
							userhtml+="<li class=\"ele\"  title='"+name+"'>";
					}
					userhtml+="<input type='hidden' class='logo' value=\""+biglogo+"\">";
					userhtml+="<input type='hidden' class='uid' value=\""+uid+"\">";
					userhtml+="<input type='hidden' class='name' value=\""+name+"\">";
					userhtml+="<a href=\""+jQ("#ctxVal").val()+"/myclip/user.html?"+uid+"\" style=\"background:url('"+smalllogo+"')\"></a>";
					userhtml+="</li>";
					}
				userhtml+="</ul>";
				if(!isconfirmevent){
					//if(processstatus==0||processstatus==-1){
						if(reliedclip==0&&isuserself){
							userhtml+="<div class=\"continueadd\">";
							userhtml+="<a onclick='showContactDetailTip(this,"+finaleventid+");'></a>";
							userhtml+="<span class=\"tip\">继续添加好友，一起同行？</span>";
							userhtml+="</div>";
							if(interestedcount>0)
								userhtml+="<button class=\"confirmevent\" onclick=\"showConfirmEvent(this,'"+finaleventid+"');\"></button>";
						}else{
							userhtml+="<button class=\"forwardevent\" onclick=\"showForwardEvent(this,'"+finaleventid+"');\"></button>";
						}
					//}
				}else{
					//if(processstatus==0||processstatus==-1)
						if(reliedclip>0||!isuserself){
							userhtml+="<button class=\"forwardevent\" onclick=\"showForwardEvent(this,'"+finaleventid+"');\"></button>";
						}
				}
				jQ("#aboutpppart-title").nextAll().remove();
				jQ("#aboutpppart-title").after(userhtml);
			}else{
				jQ("#aboutpppart-title").text("找你的朋友一起参与吧！");
				var userhtml;
				userhtml="<button class=\"forwardevent\" onclick=\"showForwardEvent(this,'"+finaleventid+"');\"></button>";
				jQ("#aboutpppart-title").nextAll().remove();
				jQ("#aboutpppart-title").after(userhtml);
			}
			jQ("#aboutpppart-title").parent().show();
		}
	});
	
}

function showForwardEvent(obj,liid){
	var btnline=jQ(obj).parent();
	if(btnline.nextAll("div.zonecontent").length>0){
		if(btnline.nextAll("div.zonecontent").css("display")=="none"){
			btnline.nextAll("div.zonecontent").show();
		}else{
			btnline.nextAll("div.zonecontent").hide();
		}
	}else{
		btnline.after(jQ("#zonecontent-out").clone().html());
//		btnline.nextAll("div.zonecontent").attr("id","zone_"+liid);
	}
	
}

function loadCCShareInfo(eventid){
	var finaleventid=eventid;
	jQ("#clippoint-zone ul.stat_button_choose>li").bind("click",function(){
		var thisclass=jQ(this).attr("class");
		if(jQ("#clippoint-zone div.pointto").hasClass(thisclass)){
			return;
		}else{
			jQ("#clippoint-zone div.pointto").attr("class","pointto").addClass(thisclass);
			jQ("#zone-interest").hide();
			jQ("#zone-forward").hide();
			jQ("#zone-favor").hide();
			var effectzoneid=jQ(this).attr("effectzone");
			jQ("#"+effectzoneid).show();
		}
	});
	jQ.ajax({
		type: "POST",
		url:"manageClipAjax!loadCCShareInfo.action",
		data:{
			eventid:finaleventid
		},
		success:function(data){
			var interestcount=data.interestcount;
			var forwardcount=data.forwardcount;
			var favorcount=data.favorcount;
			jQ("#clippoint-zone").data("interestcount",interestcount);
			jQ("#clippoint-zone").data("forwardcount",forwardcount);
			jQ("#clippoint-zone").data("favorcount",favorcount);
			jQ("#clippoint-zone ul.stat_button_choose>li.interest_btn").attr("title",interestcount+" 位用户");
			jQ("#clippoint-zone ul.stat_button_choose>li.forward_btn").attr("title",forwardcount+" 位用户");
			jQ("#clippoint-zone ul.stat_button_choose>li.favor_btn").attr("title",favorcount+" 位用户");
			var html="";
			if(interestcount>0){
				var interestpagecount=data.interestpagecount;
				var interestusers=data.interestusers;
				jQ("#clippoint-zone").data("in-currentpage",0);
				jQ("#clippoint-zone").data("in-pagecount",interestpagecount);
				html+="<ul class='sharemembers' id='zone-interest'>";
				for(var i=0;i<interestusers.length;i++){
					var userobj=interestusers[i];
					var uid=userobj.uid;
					var name=userobj.name;
					var smalllogo=userobj.smalllogo;
					var biglogo=userobj.biglogo; 
					html+="<li class='element' title=\""+name+"\">";
					html+="<input type='hidden' class='uid' value=\""+uid+"\">";
					html+="<input type='hidden' class='name' value=\""+name+"\">";
					html+="<a href=\""+jQ("#ctxVal").val()+"/myclip/user.html?"+uid+"\" style=\"background:url('"+smalllogo+"')\"></a>";
					html+="</li>";
				}
				for(var i=interestusers.length;i<10;i++){
					html+="<li class='element'></li>";
				}
				if(interestpagecount>1)
					html+="<li class=\"opt\"><a>换一换</a></li>";
				html+="</ul>";
			}else{
				jQ("#clippoint-zone").data("in-currentpage",0);
				jQ("#clippoint-zone").data("in-pagecount",0);
				html+="<p class='info' id='zone-interest'>暂时还未有人表示感兴趣</p>";
			}
			if(forwardcount>0){
				var forwardpagecount=data.forwardpagecount;
				var forwardusers=data.forwardusers;
				jQ("#clippoint-zone").data("fw-currentpage",0);
				jQ("#clippoint-zone").data("fw-pagecount",forwardpagecount);
				html+="<ul class='sharemembers' id='zone-forward' style='display:none;'>";
				for(var i=0;i<forwardusers.length;i++){
					var userobj=forwardusers[i];
					var uid=userobj.uid;
					var name=userobj.name;
					var smalllogo=userobj.smalllogo;
					var biglogo=userobj.biglogo; 
					html+="<li class='element' title=\""+name+"\">";
					html+="<input type='hidden' class='uid' value=\""+uid+"\">";
					html+="<input type='hidden' class='name' value=\""+name+"\">";
					html+="<a href=\""+jQ("#ctxVal").val()+"/myclip/user.html?"+uid+"\" style=\"background:url('"+smalllogo+"')\"></a>";
					html+="</li>";
				}
				for(var i=forwardusers.length;i<10;i++){
					html+="<li class='element'></li>";
				}
				if(forwardpagecount>1)
					html+="<li class=\"opt\"><a>换一换</a></li>";
				html+="</ul>";
			}else{
				jQ("#clippoint-zone").data("fw-currentpage",0);
				jQ("#clippoint-zone").data("fw-pagecount",0);
				html+="<p class='info' id='zone-forward' style='display:none;'>暂时还未有人呼朋唤友</p>";
			}
			if(favorcount>0){
				var favorpagecount=data.favorpagecount;
				var favorusers=data.favorusers;
				jQ("#clippoint-zone").data("fv-currentpage",0);
				jQ("#clippoint-zone").data("fv-pagecount",forwardpagecount);
				html+="<ul class='sharemembers' id='zone-favor' style='display:none;'>";
				for(var i=0;i<favorusers.length;i++){
					var userobj=favorusers[i];
					var uid=userobj.uid;
					var name=userobj.name;
					var smalllogo=userobj.smalllogo;
					var biglogo=userobj.biglogo; 
					html+="<li class='element' title=\""+name+"\">";
					html+="<input type='hidden' class='uid' value=\""+uid+"\">";
					html+="<input type='hidden' class='name' value=\""+name+"\">";
					html+="<a href=\""+jQ("#ctxVal").val()+"/myclip/user.html?"+uid+"\" style=\"background:url('"+smalllogo+"')\"></a>";
					html+="</li>";
				}
				for(var i=favorusers.length;i<10;i++){
					html+="<li class='element'></li>";
				}
				if(favorpagecount>1)
					html+="<li class=\"opt\"><a>换一换</a></li>";
				html+="</ul>";
			}else{
				jQ("#clippoint-zone").data("fv-currentpage",0);
				jQ("#clippoint-zone").data("fv-pagecount",0);
				html+="<p class='info' id='zone-favor' style='display:none;'>暂时还未有人表示喜欢</p>";
			}
			jQ("#aboutccpart_pointto").nextAll().remove();
			jQ("#aboutccpart_pointto").after(html);
			if(interestcount>0&&interestpagecount>1){
				jQ("#zone-interest>li.opt>a").bind("click",{pageclass:"interest"},changeSharePage);
			}
			if(forwardcount>0&&forwardpagecount>1){
				jQ("#zone-forward>li.opt>a").bind("click",{pageclass:"forward"},changeSharePage);
			}
			if(favorcount>0&&favorpagecount>1){
				jQ("#zone-favor>li.opt>a").bind("click",{pageclass:"favor"},changeSharePage);
			}
			jQ("#clippoint-zone div.aboutccpart").show();
		}
	});
}

function changeSharePage(event){
	var pageidhead="zone-";
	var pageclass=event.data.pageclass;
	var currentpage=0;
	var pagecount=0;
	if(pageclass=='interest'){
		currentpage=eval(jQ("#clippoint-zone").data("in-currentpage"));
		pagecount=eval(jQ("#clippoint-zone").data("in-pagecount"));
	}else if(pageclass='forward'){
		currentpage=eval(jQ("#clippoint-zone").data("fw-currentpage"));
		pagecount=eval(jQ("#clippoint-zone").data("fw-pagecount"));
	}else if(pageclass='favor'){
		currentpage=eval(jQ("#clippoint-zone").data("fv-currentpage"));
		pagecount=eval(jQ("#clippoint-zone").data("fv-pagecount"));
	}
	if(currentpage==pagecount-1){
		currentpage=0;
	}else{
		currentpage++;
	}
	if(pageclass=='interest'){
		jQ("#clippoint-zone").data("in-currentpage",currentpage);
	}else if(pageclass='forward'){
		jQ("#clippoint-zone").data("fw-currentpage",currentpage);
	}else if(pageclass='favor'){
		jQ("#clippoint-zone").data("fv-currentpage",currentpage);
	}
	var eventid=eval(jQ("#clipevent-eventid").val());
	var seid=eval(jQ("#clipevent-eventid").data("seid"));
	var dealeventid=0;
	if(seid>0){
		dealeventid=seid;
	}else{
		dealeventid=eventid;
	}
	jQ.ajax({
		type: "POST",
		url:"manageClipAjax!pagingShareInfo.action",
		data:{
			eventid:dealeventid,
			currentpage:currentpage,
			pageclass:pageclass
		},
		success:function(data){
			if(data.result){
				var users=data.users;
				var html="";
				for(var i=0;i<users.length;i++){
					var userobj=users[i];
					var uid=userobj.uid;
					var name=userobj.name;
					var smalllogo=userobj.smalllogo;
					var biglogo=userobj.biglogo; 
					html+="<li class='element' title=\""+name+"\">";
					html+="<input type='hidden' class='uid' value=\""+uid+"\">";
					html+="<input type='hidden' class='name' value=\""+name+"\">";
					html+="<a href=\""+jQ("#ctxVal").val()+"/myclip/user.html?"+uid+"\" style=\"background:url('"+smalllogo+"')\"></a>";
					html+="</li>";
				}
				for(var i=users.length;i<10;i++){
					html+="<li class='element'></li>";
				}
				html+="<li class=\"opt\"><a>换一换</a></li>";
				jQ("#"+pageidhead+pageclass).hide();
				jQ("#"+pageidhead+pageclass).empty().append(html);
				jQ("#"+pageidhead+pageclass).fadeIn();
				jQ("#"+pageidhead+pageclass).find("li.opt>a").bind("click",{pageclass:pageclass},changeSharePage);
				
			}else{
				alert("加载出错");
			}
		}
	});
}

function clockForDetail(event){
	var curobj=jQ(event.currentTarget);
	var clocktime=eval(curobj.data("clocktime"));
	if(clocktime>0){
		var eventid=jQ("#clipevent-eventid").val();
		jQ.ajax({
			type: "POST",
			url:"eventAjax!cancelClock.action",
			data:{
				eventid:eventid
			},
			success:function(data){
				if(data!=null){
					var dataObj=eval("("+data+")");//转换为json对象
					if(dataObj['result']){
						curobj.data("clocktime",0);
						curobj.attr("class","salert");
						jQ("#clipevent-clockval").empty().append("<i>暂无</i>");
						
					}else{
						
					}
				}
			}
		});
	}else{
		var setobj=curobj.next("div.setalertzone");
		if(eval(jQ("#var_hasmobile").val())){
			setobj.find("a.mobilemsg").show();
		}else{
			setobj.find("a.mobilemsg").hide();
		}
		
		setobj.find("a.setalertconfirm").unbind("click").bind("click",function(){
			var inputdate=jQ(this).prevAll("input.input");
			var alertdateval=inputdate.val();
			if(alertdateval==null||alertdateval.length<=0){
				alert("请选择提醒的时间。");
				return;
			}else{
			}
			
			var alertdate=inputdate.datepicker( "getDate" );
			var alerthourobj=jQ(this).prevAll("div.hourbg").find("input.hminput");
			var alertminobj=jQ(this).prevAll("div.minbg").find("input.hminput");
			var alerthour=eval(alerthourobj.val());
			var alertmin=eval(alertminobj.val());
			alertdate.setHours(alerthour);
			alertdate.setMinutes(alertmin);
			var alertlong=alertdate.getTime();
			var nowdate=new Date();
			if(alertlong<nowdate){
				alert("提醒的时间应该是将来的时间。");
				return;
			}else{
			}
			var mobilenotice=0;
			var isChecked=eval(jQ(this).prevAll("span.methodchoose").find("a.mobilemsg").attr("mobilenotice"));
			if(isChecked&&eval(jQ("#var_hasmobile"))){
				mobilenotice=1;
			}
			var eventid=jQ("#clipevent-eventid").val();
			jQ.ajax({
				type: "POST",
				url:"eventAjax!addEventClock.action",
				data:{
					eventid:eventid,
					alerttime:alertlong,
					mobilenotice:mobilenotice
				},
				success:function(data){
					
					if(data!=null){
						var dataObj=eval("("+data+")");//转换为json对象
						if(dataObj.result){
							setobj.hide();
							curobj.data("clocktime",alertlong);
							curobj.attr("class","calert");
							jQ("#clipevent-clockval").empty().append(formateDetailTime(alertlong));
						}else{
						}
					}
				}
			});
		});
		setobj.find("a.setalertcancel").unbind("click").bind("click",function(){
			setobj.hide();
		});
		
		
		setobj.show();
		
	}
	
}

function showConfirmEvent(obj,liid){
	var btnobj=jQ(obj);
	var ulobj=btnobj.prevAll("ul.sharemembers");
	var itonlist=ulobj.find("li.iton");
	if(itonlist.length<=0){
		clip_tips("暂时还未任何好友表态感兴趣，不能进行一拍即合操作。");
	}else{
		jQ("#inf_interestlist").empty();
		var html="";
		jQ("#inf_interestlist").data("itonlength",itonlist.length);
		if(itonlist.length>15){
			var pagecount=Math.ceil(itonlist.length/15);
			jQ("#inf_interestlist").data("pagecount",pagecount);
			jQ("#inf_interestlist").data("currentpage",0);
			for(var i=0;i<15;i++){
				var logo=jQ(itonlist[i]).find("input.logo").val();
				var uid=jQ(itonlist[i]).find("input.uid").val();
				var name=jQ(itonlist[i]).find("input.name").val();
				html+="<li title=\""+name+"\">";
				html+="<img src=\""+logo+"\"/>"
				html+="</li>";
			}
			jQ("#inf_interest_next").show();
			jQ("#inf_interest_next").unbind("click").bind("click",function(){
				var currentpage=eval(jQ("#inf_interestlist").data("currentpage"));
				var pagecount=eval(jQ("#inf_interestlist").data("pagecount"));
				var itonlength=eval(jQ("#inf_interestlist").data("itonlength"));
				if(currentpage+1>=pagecount){
					jQ(this).hide();
					return;
				}else{
					if(currentpage==0)
						jQ("#inf_interest_prev").show();
					currentpage++;
					var html="";
					for(var i=0;i<15;i++){
						var index=i+15*currentpage;
						if(index==itonlength)
							break;
						var logo=jQ(itonlist[i]).find("input.logo").val();
						var uid=jQ(itonlist[i]).find("input.uid").val();
						var name=jQ(itonlist[i]).find("input.name").val();
						html+="<li title=\""+name+"\">";
						html+="<img src=\""+logo+"\"/>"
						html+="</li>";
					}
					jQ("#inf_interestlist").data("currentpage",currentpage);
					jQ("#inf_interestlist").empty().append(html);
					if(currentpage==pagecount-1){
						jQ(this).hide();
					}
				}
			});
			jQ("#inf_interest_prev").unbind("click").bind("click",function(){
				var currentpage=eval(jQ("#inf_interestlist").data("currentpage"));
				var pagecount=eval(jQ("#inf_interestlist").data("pagecount"));
				var itonlength=eval(jQ("#inf_interestlist").data("itonlength"));
				if(currentpage-1<0){
					jQ(this).hide();
					return;
				}else{
					if(currentpage+1==pagecount)
						jQ("#inf_interest_next").show();
					currentpage--;
					var html="";
					for(var i=0;i<15;i++){
						var index=i+15*currentpage;
						if(index==itonlength)
							break;
						var logo=jQ(itonlist[i]).find("input.logo").val();
						var uid=jQ(itonlist[i]).find("input.uid").val();
						var name=jQ(itonlist[i]).find("input.name").val();
						html+="<li title=\""+name+"\">";
						html+="<img src=\""+logo+"\"/>"
						html+="</li>";
					}
					jQ("#inf_interestlist").data("currentpage",currentpage);
					jQ("#inf_interestlist").empty().append(html);
					if(currentpage==0){
						jQ(this).hide();
					}
						
						
				}
			});
		}else{
			itonlist.each(function(){
				var logo=jQ(this).find("input.logo").val();
				var uid=jQ(this).find("input.uid").val();
				var name=jQ(this).find("input.name").val();
				html+="<li title=\""+name+"\">";
				html+="<img src=\""+logo+"\"/>"
				html+="</li>";
			});
		}
		
		jQ("#inf_interestlist").append(html);
		var btnoffset=btnobj.offset();
		jQ("#confirmEventInterface").css({"top":btnoffset.top-200,"left":btnoffset.left-360});
		jQ("#inf_interest_confirm").data("eventid",jQ("#"+liid).data("eventid"));
		jQ("#inf_interest_confirm").data("liid",liid);
		jQ("#inf_interest_confirm").unbind("click").bind("click",confirmEventOpt);
		jQ("#confirmEventInterface").show();
	}
}

function confirmEventOpt(){
	var eventid=eval(jQ("#clipevent-eventid").val());
	var btnObj=jQ(this);
	jQ.ajax({
		type: "POST",
		url:"eventAjax!confirmEvent.action",
		data:{
			eventid:eval(eventid)
		},
		success:function(data){
			if(data.result){
				jQ("#confirmEventInterface").hide();
				jQ("#inf_interestlist").empty();
				var topobj=jQ("#clippoint-zone").prevAll("div.part_right_top");
				topobj.append("<img src=\""+jQ("#ctxVal").val()+"/image/confirmevent_status.png\"></img>");
				jQ("#aboutpppart-title").text("参加的好友");
				var ulobj=jQ("#aboutpppart-title").next("ul.sharemembers");
				ulobj.find("li").each(function(){
					if(!jQ(this).hasClass("iton"))
						jQ(this).remove();
				});
				ulobj.nextAll().remove();
			}else{
				
			}
		}
	});
}

function closeConfirm_Inf(){
	jQ("#confirmEventInterface").hide();
	jQ("#inf_interestlist").empty();
	jQ("#inf_interest_confirm").removeData("eventid");
	jQ("#inf_interest_confirm").unbind("click");
}

function initDetailTimeCalendar(starttime,iswholeday,endtime){
	var startdate=new Date();
	startdate.setTime(starttime);
	var year=startdate.getFullYear();
	var month=startdate.getMonth();
	startdate=new Date(year,month,startdate.getDate());
	var enddate;
	var issameday=false;
	if(!iswholeday){
		enddate=new Date();
		enddate.setTime(endtime);
		enddate=new Date(enddate.getFullYear(),enddate.getMonth(),enddate.getDate());
		issameday=startdate.getTime()==enddate.getTime();
	}else{
		issameday=true;
	}
	detailtimemonth(null,startdate,enddate,issameday,year,month);
}

function detailtimemonth(event,startdate,enddate,issameday,year,month){
	if(typeof(startdate)=='undefined'){
		startdate=event.data.startdate;
		issameday=event.data.issameday;
		enddate=event.data.enddate;
		month=event.data.month;
		year=event.data.year;
	}
	var firstDateOfMonth=new Date(year,month,1);
	var title=firstDateOfMonth.pattern("yyyy年MM月");
	jQ("#calendarzone div.title span.title").empty().append(title);
	var week2=firstDateOfMonth.getDay();
	var week1=0;
	var startfromdate=new Date(year,month,1);
	if(week2>week1){
		startfromdate.setDate(firstDateOfMonth.getDate() -week2);
	}
	var endyear,endmonth;
	if(month==11){
		endmonth=0;
		endyear=year+1;
	}else{
		endmonth=month+1;
		endyear=year;
	}
	
	var endDateOfMonth=new Date(endyear,endmonth,1);
	endDateOfMonth.setDate(endDateOfMonth.getDate() -1);
	var week6=6;
	var week5=endDateOfMonth.getDay();
	
	
	var endtodate=new Date(endyear,endmonth,1);
	endtodate.setDate(endtodate.getDate() -1);
	if(week5<week6){
		endtodate.setDate(endDateOfMonth.getDate()+ (week6-week5));
	}
	var index=0;
	
	while(startfromdate.getTime()<=endtodate.getTime()){
		var tdobj=jQ("#tddetail"+index);
		tdobj.empty().append(startfromdate.getDate());
		tdobj.removeClass();
		if(startfromdate.getMonth()!=firstDateOfMonth.getMonth(0)){
			if(!issameday){
				if(startfromdate.getTime()>=startdate.getTime()&&startfromdate.getTime()<enddate.getTime()+1){
					tdobj.addClass("selected");
				}else{
					tdobj.addClass("other");
				}
			}else
				tdobj.addClass("other");
		}else{
			if(issameday){
				if(startfromdate.getTime()==startdate.getTime()){
					tdobj.addClass("selected");
				}
			}else{
				if(startfromdate.getTime()>=startdate.getTime()&&startfromdate.getTime()<enddate.getTime()+1){
					tdobj.addClass("selected");
				}
			}
		}
		index++;
		startfromdate.setDate(startfromdate.getDate() +1);
	}
	if(index==28){
		jQ("#detailsharetimetable tr[line=4]").hide();
	}else if(index==35){
		jQ("#detailsharetimetable tr[line=4]").show();
		jQ("#detailsharetimetable tr[line=5]").hide();
	}else{
		jQ("#detailsharetimetable tr[line=4]").show();
		jQ("#detailsharetimetable tr[line=5]").show();
	}
	
	if(issameday){
		jQ("#calendarzone div.title a").addClass("none");
	}else{
		if(startdate.getTime()<firstDateOfMonth.getTime()){
			var temp1=new Date(firstDateOfMonth.getFullYear(),firstDateOfMonth.getMonth(),firstDateOfMonth.getDate());
			temp1.setMonth(temp1.getMonth()-1);
			var tempyear=temp1.getFullYear();
			var tempmonth=temp1.getMonth();
			jQ("#calendarzone div.title a.prev").removeClass("none").unbind("click")
				.bind("click",{startdate:startdate,enddate:enddate,issameday:issameday,year:tempyear,month:tempmonth},detailtimemonth);
		}else{
			jQ("#calendarzone div.title a.prev").addClass("none").unbind("click");
		}
		var tempdate=new Date(endDateOfMonth.getFullYear(),endDateOfMonth.getMonth(),endDateOfMonth.getDate());
		tempdate.setDate(tempdate.getDate()+ 1);
		if(enddate.getTime()>tempdate.getTime()){
			var tempyear=tempdate.getFullYear();
			var tempmonth=tempdate.getMonth();
			jQ("#calendarzone div.title a.next").removeClass("none").unbind("click")
			.bind("click",{startdate:startdate,enddate:enddate,issameday:issameday,year:tempyear,month:tempmonth},detailtimemonth);
		}else{
			jQ("#calendarzone div.title a.next").addClass("none").unbind("click");
		}
	}
}

function initStatButton(cliptype,eventid){
	if(cliptype==3){
		var cureventid=eventid;
		jQ("#share_button").unbind("click").bind("click",function(){
			if(jQ(this).find("a").hasClass("onit")){
				return;
			}else{
				jQ(this).find("a").removeClass().addClass("onit");
				jQ("#invite_button").find("a").removeClass().addClass("outit");
				jQ("#invite_statpart").hide();
				loadCurrentUserContactInShare(cureventid);
				jQ("#share_statpart").show();
			}
		});
		jQ("#invite_button").unbind("click").bind("click",function(){
			if(jQ(this).find("a").hasClass("onit")){
				return;
			}else{
				jQ(this).find("a").removeClass().addClass("onit");
				jQ("#share_button").find("a").removeClass().addClass("outit");
				jQ("#share_statpart").hide();
				jQ("#invite_statpart").show();
			}
		});
	}
}

function loadCurrentUserContactInShare(eventid){
		jQ.ajax({
			type: "POST",
			url:"shareAjax!loadsfFriends.action",
			data:{
				eventid:eval(eventid)
			},
			success:function(data){
				if(data!=null){
					var length=jQ(data).find("User").length;
					jQ("#friendscount").empty().append(length);
					if(length==0){
						jQ("#checkfriendsbtn").hide();
					}else{
						var html="";
						jQ(data).find("User").each(function(i){
							var nickname=jQ(this).find("nickname").text();
							var realname=jQ(this).find("realname").text();
							var uid=jQ(this).attr("uid");
							if(i<6){
								html+="<li index="+i+" class=\"list\">";
							}else{
								html+="<li style='display:none;' index="+i+" class=\"list\">";
							}
							html+="<a href='"+jQ("#ctxVal").val()+"/myclip/user.html?"+uid+"'>";
							html+="<span class='nickname'>"+nickname+"</span>";
							html+="<span class='out'>( <span class='realname'>"+realname+"</span> )</span>";
							html+="</a>";
							html+="</li>";
						});
						if(jQ(data).find("User").length>6){
							html+="<li class=\"paging\"><a class=\"next\" title=\"下页\"></a><a class=\"prev\" title=\"上页\"></a></li>";
						}
						jQ("#friendslist").empty().append(html).hide();
						if(jQ(data).find("User").length>6){
							var maxcount=jQ(data).find("User").length;
							jQ("#friendslist").data("page",0);
							jQ("#friendslist").data("maxcount",maxcount);
							jQ("#friendslist").data("maxpage",Math.ceil(maxcount/6));
							jQ("#friendslist li.paging a.next").unbind("click").bind("click",shareFriendsNextPage);
							jQ("#friendslist li.paging a.prev").unbind("click").bind("click",shareFriendsPrevPage);
						}
						jQ("#checkfriendsbtn").show().unbind("click").bind("click",showfriendsaboutshare);
					}
				}
			}
		});
}

function shareFriendsNextPage(){
	var page=eval(jQ("#friendslist").data("page"));
	var maxpage=eval(jQ("#friendslist").data("maxpage"));
	var maxcount=eval(jQ("#friendslist").data("maxcount"));
	if(page+1>=maxpage){
		return;
	}else{
		for(var i=0;i<6;i++){
			var index=page*6+i;
			jQ("#friendslist li[index="+index+"]").fadeOut("normal",function(){
				var temp=eval(jQ(this).attr("index"));
				if(temp+6<maxcount){
					jQ("#friendslist li[index="+(temp+6)+"]").fadeIn();
				}
			});
		}
		jQ("#friendslist").data("page",page+1);
	}
}

function shareFriendsPrevPage(){
	var page=eval(jQ("#friendslist").data("page"));
	var maxcount=eval(jQ("#friendslist").data("maxcount"));
	if(page-1<0){
		return;
	}else{
		var index=page*6;
		for(var i=5;i>=0;i--){
			var index=page*6+i;
			if(index>=maxcount){
				jQ("#friendslist li[index="+(index-6)+"]").fadeIn();
			}
			jQ("#friendslist li[index="+index+"]").fadeOut("normal",function(){3
				var temp=eval(jQ(this).attr("index"));
				if(temp-6>=0){
					jQ("#friendslist li[index="+(temp-6)+"]").fadeIn();
				}
			});
		}
		jQ("#friendslist").data("page",page-1);
	}
	
}

function showfriendsaboutshare(){
	if(jQ("#checkfriendsbtn").hasClass("checkfriendsopened")){
		jQ("#checkfriendsbtn").removeClass("checkfriendsopened");
		jQ("#friendslist").hide();
	}else{
		jQ("#checkfriendsbtn").addClass("checkfriendsopened");
		jQ("#friendslist").show();
	}
}


function loadClipMessage(eventid){
	jQ("#clipevent-messages").data("replyid",eventid);
	jQ.ajax({
		type: "POST",
		url:"eventAjax!loadClipMessage.action",
		data:{
			eventid:eval(eventid)
		},
		success:function(data){
			if(data!=null){
				var msglength=jQ(data).find("Clipmessage").length;
				if(msglength==0){
					return;
				}else{
					jQ("#clipmessage-count").empty().append(msglength+"条");
				}
				jQ("#clipevent-eventid").data("msglength",msglength);
				var html="";
				jQ(data).find("Clipmessage").each(function(i){
					var content=jQ("content",this).text();
					var email=jQ(this).find("email").text();
					var replytime=eval(jQ(this).find("replytime").text());
					var name=jQ(this).find("name").text();
					var uid=jQ(this).find("uid").text();
					var logo=jQ(this).find("logo").text();
					var useriscc=eval(jQ(this).find("useriscc").text());
					var msgtype=eval(jQ(this).find("msgtype").text());
					var msgtypestr=jQ(this).find("msgtypestr").text();
					var replystr=formateDetailTime(replytime);
					var tmp="";
					if(i==0)
						tmp="<li class='leave_msg' style='margin-top:8px;'>";
					else
						tmp="<li class='leave_msg'>";
					tmp+="<dt>";
					tmp+="<a class='logo' style='background:url(\""+logo+"\")' href='"+jQ("#ctxVal").val()+"/myclip/user.html?"+uid+"'></a>";
					tmp+="<span class='fid'>";
					tmp+="<a href='"+jQ("#ctxVal").val()+"/myclip/user.html?"+uid+"'>"+name+"</a>";
					tmp+="</span>";
					if(useriscc)
						tmp+="<span class='v_icon'></span>";
					if(msgtype==0)
						tmp+="<b class='comment'>";
					else if(msgtype==1)
						tmp+="<b class='interest'>";
					else if(msgtype==2)
						tmp+="<b class='uninterest'>";
					else if(msgtype==3)
						tmp+="<b class='confirm'>";
					else if(msgtype==4)
						tmp+="<b class='forward'>";
					else if(msgtype==5)
						tmp+="<b class='quit'>";
					else if(msgtype==6)
						tmp+="<b class='favor'>";
					else if(msgtype==7)
						tmp+="<b class='unfavor'>";
					tmp+=msgtypestr+"</b>";
					if(msgtype==0){
						tmp+="<div>";
						tmp+=htmlData(content);
						tmp+="</div>";
					}
					tmp+="<span class='time'>";
					tmp+=replystr;
					tmp+="</span></dt>";
					tmp+="</li>";
					html+=tmp;
				});
				jQ("#clipevent-messages").empty().append(html);
			}
		}
	});
}

function initDetailOptBtn(isuserself){
	var del=jQ("#clipevent-opt a.del");
	var join=jQ("#clipevent-opt a.join");
	var reject=jQ("#clipevent-opt a.reject");
	var ignore=jQ("#clipevent-opt a.ignore");
	var undo=jQ("#clipevent-opt a.undo");
	var deletejoin=jQ("#clipevent-opt a.delete");
	var alreadyfw=jQ("#clipevent-opt a.alreadyfw");
	var forwardshare=jQ("#clipevent-opt a.forwardshare");
	var saveshare=jQ("#clipevent-opt a.saveshare");
	if(del.css("display")!='none'){
		if(isuserself){
			del.unbind("click").bind("click",deleteDetailEvent);
		}else{
			del.unbind("click").bind("click",cancelShareEvent);
		}
	}
	if(join.css("display")!='none'){
		join.unbind("click").bind("click",joinDetailEvent);
	}
	if(reject.css("display")!='none'){
		reject.unbind("click").bind("click",rejectDetailEvent);
	}
	if(ignore.css("display")!='none'){
		ignore.unbind("click").bind("click",ignoreDetailEvent);
	}
	if(undo.css("display")!='none'){
		undo.unbind("click").bind("click",deleteDetailEvent);
	}
	if(deletejoin.css("display")!='none'){
		deletejoin.unbind("click").bind("click",deleteDetailEvent);
	}
	if(alreadyfw.css("display")!='none'){
		alreadyfw.unbind("click").bind("click",alreadyfwEvent);
	}
	if(forwardshare.css("display")!='none'){
		jQ("#shareoutzone").show();
		initShareOutofSite();
		forwardshare.unbind("click").bind("click",forwardshareEvent);
		jQ("span.share-title input[name=shareraido]:first").click();
		jQ("span.share-title input[name=shareraido]").click(function(){
			var val=eval(jQ(this).val());
			if(val){
				jQ("#share-contactchoose").fadeIn();
			}else{
				jQ("#share-contactchoose").fadeOut();
			}
		});
	}
	if(saveshare.css("display")!='none'){
		saveshare.unbind("click").bind("click",saveshareEvent);
	}
}

function initDetailShareOutofSite(){
	jQ("#shareoutzone div.shareoutopt a").unbind("click");
	jQ("#shareoutzone div.shareoutopt a.renren").bind("click",function(){
		var shareid=jQ("#clipevent-eventid").data("shareid");
		var title=jQ("#clipevent-eventid").data("title");
		var starttime=eval(jQ("#clipevent-eventid").data("starttime"));
		var day=new Date();
		day.setTime(starttime);
		var startstr=day.pattern("yyyy年MM月dd日");
		
		
		var url="http://"+document.domain+jQ("#ctxVal").val()+"/myclip/clip_detail.html?"+shareid;
		window.open(
		'http://www.connect.renren.com/share/sharer?url='+url
		+'&title=档期分享：'+startstr+'  '+title+'    '+'更多详情请点击',
		'_blank',
		'height=290,width=510,top=200,left=430,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no, status=no'); 
	});
	
	jQ("#shareoutzone div.shareoutopt a.kaixin").bind("click",function(){
		var shareid=jQ("#clipevent-eventid").data("shareid");
		var title=jQ("#clipevent-eventid").data("title");
		var starttime=eval(jQ("#clipevent-eventid").data("starttime"));
		var day=new Date();
		day.setTime(starttime);
		var startstr=day.pattern("yyyy年MM月dd日");
		var url="http://"+document.domain+jQ("#ctxVal").val()+"/myclip/clip_detail.html?"+shareid;
		window.open(
		'http://www.kaixin001.com/repaste/share.php?rurl='+url
		+'&rtitle=档期分享'
		+'&rcontent='+startstr+'  '+title+'    '+'更多详情请点击',
		'_blank',
		'height=500,width=700,top=200,left=410,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no, status=no');
		
	});
	
	jQ("#shareoutzone div.shareoutopt a.sina").bind("click",function(){
		var shareid=jQ("#clipevent-eventid").data("shareid");
		var url="http://"+document.domain+jQ("#ctxVal").val()+"/myclip/clip_detail.html?"+shareid;
		var title=jQ("#clipevent-eventid").data("title");
		var starttime=eval(jQ("#clipevent-eventid").data("starttime"));
		var day=new Date();
		day.setTime(starttime);
		var startstr=day.pattern("yyyy年MM月dd日");
		var param = {
		    url:url,
		    type:'3',
		    title:'档期分享：'+startstr+'  '+title+'    '+'更多详情请点击',
		    pic:'',
		    ralateUid:'2618696840',
			language:'zh_cn',
		    rnd:new Date().valueOf()
		  }
		var temp = [];
		for( var p in param ){
			temp.push(p + '=' + encodeURIComponent( param[p] || '' ) )
		}
		
		window.open(
				'http://service.weibo.com/share/share.php?' + temp.join('&') ,
				'_blank',
		'height=520,width=607,top=150,left=410,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no, status=no');
	});
	jQ("#shareoutzone div.shareoutopt a.douban").bind("click",function(){
		var shareid=jQ("#shareoutzone").data("acceptshareid");
		var title=jQ("#clipevent-eventid").data("title");
		var shareid=jQ("#clipevent-eventid").data("shareid");
		var url="http://"+document.domain+jQ("#ctxVal").val()+"/myclip/clip_detail.html?="+shareid;
		var starttime=eval(jQ("#clipevent-eventid").data("starttime"));
		var day=new Date();
		day.setTime(starttime);
		var startstr=day.pattern("yyyy年MM月dd日");
		window.open(
		'http://www.douban.com/recommend/?url='+url
		+'&title=档期分享'+
		+'&comment='+startstr+'  '+title+'    '+'更多详情请点击',
		'_blank',
		'height=370,width=505,top=300,left=450,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no, status=no');
	});
}



function saveshareEvent(){
	var eventid=jQ("#clipevent-eventid").val();
	jQ.ajax({
		type: "POST",
		url:"shareAjax!saveShareEvent.action",
		data:{
			eventid:eval(eventid)
		},
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj.result){
					alert("保存成功");
					jQ("#clipevent-eventid").data("acceptshareid",dataObj.shareid);
					jQ("#clipevent-opt a.forwardshare").show();
					jQ("#clipevent-opt a.saveshare").hide();
					jQ("#clipevent-opt a.saveshare").unbind("click");
					jQ("#clipevent-opt a.del").show();
					jQ("#clipevent-opt a.del").bind("click",cancelShareEvent);
					jQ("#clipevent-opt a.forwardshare").bind("click",forwardshareEvent);
					jQ("#shareoutzone").show();
				}else{
					alert(dataObj.msg);
					window.location.reload();
				}
			}
		}
	});
}

function forwardshareEvent(){
	position2where(jQ("#forwardshare_box"),jQ(this));
	jQ("#forwardshare_box").show();
}

function position2where(obj,posobj){
	var box = posobj.offset();
	var box_position = box.left + obj.width();
	obj.css({"top":box.top+25,"left":box.left-150});
}

function confirmshare(){
	var sharecbxval=jQ('input[name=shareraido]:checked').val();
	if(eval(sharecbxval)){
		var templength=jQ("li",jQ("#contactgrouplist")).length;
		errzone=jQ("#share-errorinfo");
		if(templength==0){
			errzone.empty();
			errzone.append("请至少选择一个指定群组。");
			errzone.show();
			return;
		}else{
			errzone.empty();
		}
		
	}
	var sharelist='';
	
	var sharecbxval=jQ('input[name=shareraido]:checked').val();
	if(eval(sharecbxval)){
		var tmphtml="";
		jQ("#contactgrouplist li").each(function(i){
			if(i==0)
				tmphtml=jQ(this).attr("groupid");
			else{
				tmphtml+=","+jQ(this).attr("groupid");
			}
		});
		sharelist=tmphtml;
	}else{
		sharelist="0";
	}
	var eventid=jQ("#clipevent-eventid").val();
	jQ.ajax({
		type: "POST",
		url:"shareAjax!forwardShareEvent.action",
		data:{
			eventid:eval(eventid),
			sharelist:sharelist
		},
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj.result){
					alert("转发成功");
					jQ("#forwardshare_box").fadeOut();
				}else{
					alert(dataObj.msg);
					window.location.reload();
				}
			}
		}
	});
}
function cancelshare(){
	jQ("#forwardshare_box").toggle();
}

function cancelShareEvent(){
	var acceptshareid=jQ("#clipevent-eventid").data("acceptshareid");
	jQ.ajax({
		type: "POST",
		url:"shareAjax!cancelShareEvent.action",
		data:{
			shareid:acceptshareid
		},
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj.result){
					alert("取消成功");
					jQ("#clipevent-opt a.forwardshare").hide().unbind("click");
					jQ("#clipevent-opt a.alreadyfw").hide().unbind("click");
					jQ("#clipevent-opt a.del").hide().unbind("click");
					
					jQ("#clipevent-opt a.saveshare").show().bind("click",saveshareEvent);
					jQ("#shareoutzone").hide();
					
				}else{
				}
			}
		}
	});
}

function alreadyfwEvent(){
	if(jQ(this).hasClass("alreadyfwopen")){
		jQ(this).removeClass("alreadyfwopen").addClass("alreadyfw");
		jQ("#forwardsharemember_box").hide();
	}else{
		jQ(this).removeClass("alreadyfw").addClass("alreadyfwopen");
		var offset=jQ(this).offset();
		jQ("#forwardsharemember_box").css({"left":offset.left+80,"top":offset.top});
		jQ("#forwardsharemember_box").show();
	}
}

function closeForwardsharemember_box(){
	jQ("#clipevent-opt a.alreadyfwopen").removeClass("alreadyfwopen").addClass("alreadyfw");
	jQ("#forwardsharemember_box").hide();
}

function modifyDetailEvent(){
	var eventid=jQ("#clipevent-eventid").val();
	var info="";
	var title="";
	info="修改档期将删除原先的档期，创建新的档期，确定继续么？";
	title="修改档期";
	var eventid=jQ("#clipevent-eventid").val();
	jQ("#viewopt_eventid").val(eventid);
	var opt=jQ("#viewopt");
	opt.bind("modifyEvent",modifyEvent);
	opt.data("function","modifyEvent")
	jQ("#viewopt_p").empty().append(info);
	jQ("#viewopt").dialog( "option", "title",title );
	jQ("#viewopt").dialog("open");
}

function modifyEvent(){
	var eventid=jQ("#viewopt_eventid").val(); 
	jQ.ajax({
		type: "POST",
		url:"eventAjax!modifyEvent.action",
		data:{
			eventid:eval(eventid)
		},
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj['result']){
					window.location.href=jQ("#ctxVal").val()+"/myclip/add_clip.html?eventid="+dataObj['eventid'];
					jQ("#viewopt").dialog("close");
				}else{
					jQ("#viewopt_p").empty().append(dataObj['msg']);
					jQ("#viewopt").dialog("close");
				}
			}
		}
	});
}

function deleteDetailEvent(event){
	var info="";
	var title="";
	if(jQ(event.currentTarget).hasClass("undo")){
		info="您确定退出档期么？";
		title="退出档期";
	}else if(jQ(event.currentTarget).hasClass("del")){
		info="您确定取消档期么？";
		title="取消档期";
	}else if(jQ(event.currentTarget).hasClass("delete")){
		info="您确定删除档期么？";
		title="删除档期";
	}
	var eventid=jQ("#clipevent-eventid").val();
	jQ("#viewopt_eventid").val(eventid);
	var opt=jQ("#viewopt");
	opt.bind("deleteEvent",deleteEvent);
	opt.data("function","deleteEvent")
	jQ("#viewopt_p").empty().append(info);
	jQ("#viewopt").dialog( "option", "title",title );
	jQ("#viewopt").dialog("open");
}

function deleteEvent(){
	var eventid=jQ("#viewopt_eventid").val(); 
	jQ.ajax({
		type: "POST",
		url:"eventAjax!deleteEvent.action",
		data:{
			eventid:eval(eventid)
		},
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj['result']){
					jQ("#clipevent-opt a").unbind("click");
					jQ("#viewopt").dialog("close");
					backPage();
				}else{
					jQ("#viewopt_p").empty().append(dataObj['msg']);
					jQ("#viewopt").dialog("close");
				}
			}
		}
	});
}

function joinDetailEvent(){
	var eventid=eval(jQ("#clipevent-eventid").val());
	jQ.ajax({
		type: "POST",
		url:"manageClipAjax!acceptInvitedClip.action",
		data:{
			eventid:eventid
		},
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj.flag){
					jQ("#clipevent-opt a.join").unbind("click").hide();
					jQ("#clipevent-opt a.reject").unbind("click").hide();
					jQ("#clipevent-opt a.alreadyaccept").show();
				}
			}
		}
	});
}

function rejectDetailEvent(event){
	var eventid=eval(jQ("#clipevent-eventid").val());
	jQ.ajax({
		type: "POST",
		url:"manageClipAjax!refuseInvitedClip.action",
		data:{
			eventid:eventid
		},
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj['result']){
					jQ("#clipevent-opt a.join").unbind("click").hide();
					jQ("#clipevent-opt a.reject").unbind("click").hide();
					jQ("#clipevent-opt a.alreadyreject").show(); 
				}
			}
		}
	});
}

function ignoreDetailEvent(event){
	var eventid=eval(jQ("#clipevent-eventid").val());
	jQ.ajax({
		type: "POST",
		url:"manageClipAjax!ignoreInvitedClip.action",
		data:{
			eventid:eventid
		},
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj['result']){
					jQ("#clipevent-opt a").unbind("click");
					invitingOptReturnBox(event.currentTarget,"忽略的档期已放入回收站");
					
				}
			}
		}
	});
}

function invitingOptReturnBox(obj,content){
	var obj_box = jQ(obj);
	var obj_offset = obj_box.offset();
	var msg_box = jQ("#accept_msg_box");
	jQ("#accept_msg_box_content").empty().append(content);
	var _top = obj_offset.top - msg_box.outerHeight() - 10;
	var _left = obj_offset.left - msg_box.outerHeight()/2;
	msg_box.css({"top":_top+"px","left":_left+"px"}).show();
	msg_box.find("div.msg_note").animate({top: 20+'px'}, 500,function(){
		setTimeout(function(){
			msg_box.find("div.msg_note").animate({top: 100+'px'},500,function(){msg_box.hide();backPage();});
		},2000);
	});
}

function initDetailTimeSelect(){
	jQ("tr.clipevent-set_clock td select.time_hour").empty();
	var html="";
	for(var i=0;i<24;i++){
		if(i==0)
			html+="<option value="+i+">0"+i+"</option>";
		else if(i<10)
			html+="<option value="+i+">0"+i+"</option>";
		else
			html+="<option value="+i+">"+i+"</option>";
	}
	jQ("tr.clipevent-set_clock td select.time_hour").append(html);
	html="";
	jQ("tr.clipevent-set_clock td select.time_min").empty();
	for(var i=0;i<12;i++){
		var j=i*5;
		if(j==0)
			html+="<option value="+j+">0"+j+"</option>";
		else if(j<10)
			html+="<option value="+j+">0"+j+"</option>";
		else
			html+="<option value="+j+">"+j+"</option>";
	}
	jQ("tr.clipevent-set_clock td select.time_min").append(html);
}

function changeMobileStatus(obj){
	if(jQ(obj).hasClass("mobilemsgonit")){
		jQ(obj).removeClass("mobilemsgonit");
		jQ(obj).attr("mobilenotice",0);
	}else{
		jQ(obj).addClass("mobilemsgonit");
		jQ(obj).attr("mobilenotice",1);
	}
		
}

function submitReply(){
	var content=jQ.trim(jQ("#replycontent").val());
	if(content==null||content.length==0){
		jQ("#replyzoneerror").empty().append("回复内容不能为空。");
	}else{
		if(content.length>255){
			jQ("#replyzoneerror").empty().append("回复内容不能超过255个字符。");
		}else{
			jQ.ajax({
				type: "POST",
				url:"eventAjax!addreply.action",
				data:{
					eventid:eval(jQ("#clipevent-messages").data("replyid")),
					content:content
				},
				success:function(data){
					if(data.result){
						var name="我";
						var replystr=formateDetailTime(data.replytime);
						var user_url=jQ("#var_usertype").data("smallurl");
						var uid=jQ("#var_usertype").data("uid");
						var tmp="<li class='leave_msg'>";
						tmp+="<dt>";
						tmp+="<a href='"+jQ("#ctxVal").val()+"/myclip/user.html?"+uid+"' style=\"background:url('"+user_url+"');\" class=\"logo\"></a>";
						tmp+="<span class='fid'>";
							tmp+=name;
						tmp+="</span>";
						tmp+="<b class='comment'>评论：</b>";
						tmp+="<div>";
						tmp+=htmlData(content);
						tmp+="</div>";
						tmp+="<span class='time'>";
						tmp+=replystr;
						tmp+="</span></dt>";
						tmp+="</li>";
						jQ("#clipevent-messages").prepend(tmp);
						jQ("#replycontent").val("");
					}else{
						jQ("#replyzoneerror").empty().append(dataObj.msg);
					}
				}
			});
		}
	}
}

function formateDetailTime(daytime){
	var temp=new Date();
	temp.setTime(eval(daytime));
	return temp.pattern("yyyy-MM-dd HH:mm");
}

function formateTitleTime(daytime){
	var temp=new Date();
	temp.setTime(eval(daytime));
	return temp.pattern("yyyy-MM-dd");
}

function getTypeName(eng){
	if(eng=='other'){
		return "其他";
	}else if(eng=='work'){
		return "工作";
	}else if(eng=='socal'){
		return "社交";
	}else if(eng=='sect'){
		return "私人";
	}
}

function getParameter(name){
    var paramStr=location.search;
    if(paramStr.length==0)return null;
    if(paramStr.charAt(0)!='?')return null;
    paramStr=decodeURIComponent(paramStr);
    paramStr=paramStr.substring(1);
    if(paramStr.indexOf("#")>0){
    	paramStr=paramStr.substring(0,paramStr.indexOf("#"));
    }
    if(paramStr.length==0)return null;
    var params=paramStr.split('&');
    var p = null;
    for(var i=0;i<params.length;i++){
        if(params[i].indexOf(name) >= 0){
            p = params[i].split('=');
            p = p[1];
        }
    }
    return p;
}